package com.example.demo.controller;


import com.example.demo.entity.pojo.Discusstuangouxinxi;
import com.example.demo.entity.pojo.Tuangouxinxi;
import com.example.demo.service.IDiscusstuangouxinxiService;
import com.example.demo.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 团购信息评论表 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-01-09
 */
@RestController
@RequestMapping("/discusstuangouxinxi")
public class DiscusstuangouxinxiController {
    @Autowired
    private IDiscusstuangouxinxiService  discusstuangouxinxiService;
    @PostMapping("/sel")
    public R sel(){
        List<Discusstuangouxinxi>  discusstuangouxinxis = discusstuangouxinxiService.list();
        Map<String,Object> map =  new HashMap<>();
        map.put("data",discusstuangouxinxis);
        map.put("msg","查询成功");
        map.put("code",200);
        return R.ok(map);
    }
    @PostMapping("/add")
    public R add(@RequestBody Discusstuangouxinxi discusstuangouxinxi){
        discusstuangouxinxiService.save(discusstuangouxinxi);
        Map<String,Object> map =  new HashMap<>();
        map.put("msg","添加成功");
        map.put("code",200);
        return R.ok(map);
    }
    @PostMapping("/del")
    public R del(long id){
        discusstuangouxinxiService.removeById(id);
        Map<String,Object> map =  new HashMap<>();
        map.put("msg","删除成功");
        map.put("code",200);
        return R.ok(map);
    }

}
